﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ICM_Collect_Request_Select.aspx.cs" Inherits="KPIS.GERP.GIMS.APP.APP_UI.Edit_Form.ICM_Collect_Request_Select" %>
<%@ Register Assembly="BasicFrame.WebControls.BasicDatePicker" Namespace="BasicFrame.WebControls" TagPrefix="BDP" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<%@ Register TagPrefix="custom" Namespace="KPIS.Customs.UI" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title></title>
    <link rel="StyleSheet" href="../../Styles/StyleSheet.css" type="text/css">  
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" >
        </asp:ScriptManager>
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript" src="../../Scripts/Common.js"></script>
            <script type="text/javascript">
                function onTextChangeGeneral(sender) {
                    if (sender.get_value() == "") {
                        sender.set_text("");
                    }
                }

                function ChangeDurationRequire(durationRequire, dateRequire, datePicker) {
                    var panelDuration = document.getElementById(durationRequire);
                    var panelDate = document.getElementById(dateRequire);
                    var panelDatePicker = document.getElementById(datePicker);
                    panelDuration.style.visibility = "visible";
                    panelDate.style.visibility = "hidden";
                    panelDatePicker.style.visibility = "hidden";
                }

                function ChangeDateRequire(durationRequire, dateRequire, datePicker) {
                    var panelDuration = document.getElementById(durationRequire);
                    var panelDate = document.getElementById(dateRequire);
                    var panelDatePicker = document.getElementById(datePicker);
                    panelDuration.style.visibility = "hidden";
                    panelDate.style.visibility = "visible";
                    panelDatePicker.style.visibility = "visible";
                }

                function GetRadWindow() {
                    var oWindow = null;
                    if (window.radWindow) oWindow = window.radWindow;
                    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
                    return oWindow;
                }

                function CloseWindow() {
                    GetRadWindow().Close();
                }
                
                Sys.Application.add_load(setCalendarTable);
                Sys.Application.add_load(setCalendarReqTable);
                
                function setCalendarTable() {
                    var tooltip = $find("<%= ToolTipDate.ClientID %>");
                    var calendar = $find("<%= CalendarDate.ClientID %>");                       
                    var fastNavigation = calendar._getFastNavigation();
                    fastNavigation.OnToday =
                    function()
                    {
                        var today = new Date;
                        var date = [today.getFullYear(), today.getMonth()+ 1, today.getDate()];
                        calendar.selectDate(date, true);
                        fastNavigation.Popup.Hide();  
                        var all_date = date.toString().split(",");
                        var year = parseInt(all_date[0]) + 543;
                        var month = all_date[1];
                        var day = all_date[2];
                        if (day.length == 1) {
                            day = '0' + day;
                        }
                        if (month.length == 1) {
                            month = '0' + month;
                        }

                        var maskText = $find("<%= txtDate.ClientID %>");
                        maskText.set_value(day + month + year);
                        tooltip.hide();
                    }
                }
                
                function setCalendarReqTable() {
                    var tooltip = $find("<%= ToolTipDateReq.ClientID %>");
                    var calendar = $find("<%= CalendarDateReq.ClientID %>");                       
                    var fastNavigation = calendar._getFastNavigation();
                    fastNavigation.OnToday =
                    function()
                    {
                        var today = new Date;
                        var date = [today.getFullYear(), today.getMonth()+ 1, today.getDate()];
                        calendar.selectDate(date, true);
                        fastNavigation.Popup.Hide();  
                        var all_date = date.toString().split(",");
                        var year = parseInt(all_date[0]) + 543;
                        var month = all_date[1];
                        var day = all_date[2];
                        if (day.length == 1) {
                            day = '0' + day;
                        }
                        if (month.length == 1) {
                            month = '0' + month;
                        }

                        var maskText = $find("<%= txtDateReq.ClientID %>");
                        maskText.set_value(day + month + year);
                        tooltip.hide();
                    }
                }

                function OnDateClick(calendarInstance, args) {
                    var tooltip = $find("<%= ToolTipDate.ClientID %>");
                    var fastNavigation = calendarInstance._getFastNavigation();
                    var date = args.get_renderDay().get_date().toString();
                    var all_date = date.split(",");
                    var year = parseInt(all_date[0]) + 543;
                    var month = all_date[1];
                    var day = all_date[2];
                    if (day.length == 1) {
                        day = '0' + day;
                    }
                    if (month.length == 1) {
                        month = '0' + month;
                    }

                    var maskText = $find("<%= txtDate.ClientID %>");
                    maskText.set_value(day + month + year);
                    tooltip.hide();
                }
                
                function OnDateReqClick(calendarInstance, args) {
                    var tooltip = $find("<%= ToolTipDateReq.ClientID %>");
                    var fastNavigation = calendarInstance._getFastNavigation();
                    var date = args.get_renderDay().get_date().toString();
                    var all_date = date.split(",");
                    var year = parseInt(all_date[0]) + 543;
                    var month = all_date[1];
                    var day = all_date[2];
                    if (day.length == 1) {
                        day = '0' + day;
                    }
                    if (month.length == 1) {
                        month = '0' + month;
                    }

                    var maskText = $find("<%= txtDateReq.ClientID %>");
                    maskText.set_value(day + month + year);
                    tooltip.hide();
                }
                
                function OnCalendarViewChanged(sender, step) {
                    var year = parseInt(sender.FocusedDate[0]) + 543;
                    var month = sender.FocusedDate[1];
                    document.getElementById("CalendarDate_Title").innerHTML = changeMonthNumberToName(month) + " " + year; 
                } 
                
                function OnCalendarReqViewChanged(sender, step) {
                    var year = parseInt(sender.FocusedDate[0]) + 543;
                    var month = sender.FocusedDate[1];
                    document.getElementById("CalendarDateReq_Title").innerHTML = changeMonthNumberToName(month) + " " + year; 
                } 
            </script>
        </telerik:RadCodeBlock>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackgroundPosition="None" Skin="Outlook">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxManager runat="server" ID="RadManager1">
            <AjaxSettings>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <asp:Panel ID="panelHeaderList" runat="server">
            <div class="header-grid">
                <asp:Label ID="lblHeaderList" runat="server" Text="มอบหมายงาน"></asp:Label>
            </div>
        </asp:Panel>
        <asp:Panel ID="panelList" runat="server" CssClass="font-label">
            <table cellpadding="0" cellspacing="0" width="98%">
                <tr>
                    <td>
                        <div class="font-label">
                            <table cellpadding="0" cellspacing="0" width="98%">
                                <tr>
                                    <td width="20px">
                                    </td>
                                    <td>
                                        <div class="formList-detail">
                                            <table>
                                                <tr>
                                                    <td valign="top" width="120px">
                                                        <asp:Label ID="lblYearType" runat="server" Text="lblYearType"></asp:Label>
                                                        &nbsp;:
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblBgmYear" runat="server" Text="lblBgmYear"></asp:Label>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="20px">
                                    </td>
                                    <td>
                                        <div class="formList-detail">
                                            <table>
                                                <tr>
                                                    <td valign="top" width="120px">
                                                        ระเบียบการจัดหา :
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblPcRule" runat="server" Text="lblPcRule"></asp:Label>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="20px">
                                    </td>
                                    <td>
                                        <div class="formList-detail">
                                            <table>
                                                <tr>
                                                    <td valign="top" width="120px">
                                                        ประเภทการจัดหา :
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblPcType" runat="server" Text="lblPcType"></asp:Label>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="20px">
                                    </td>
                                    <td>
                                        <div class="formList-detail">
                                            <table>
                                                <tr>
                                                    <td width="120px" valign="top">
                                                        วันที่รายการ :
                                                    </td>
                                                    <td>
                                                        <telerik:RadMaskedTextBox ID="txtDate" runat="server" Mask=" ##/##/####" 
                                                            SelectionOnFocus="SelectAll" TextWithLiterals=" //" Width="75px">
                                                        </telerik:RadMaskedTextBox>
                                                        <asp:LinkButton ID="LinkButton1" runat="server" CssClass="LinkButton">
                                                            <img alt="" src="../Image/Icon/Calendar.gif" style="border:0px;vertical-align:middle;" />
                                                        </asp:LinkButton>
                                                        <telerik:RadToolTip ID="ToolTipDate" runat="server" Animation="None" HideEvent="LeaveToolTip" Position="MiddleRight" ShowEvent="OnClick" Skin="Telerik" 
                                                        TargetControlID="LinkButton1" Modal="true">
                                                            <telerik:RadCalendar id="CalendarDate" runat="server" TitleFormat="MMMM yyyy" EnableMultiSelect="false" UseRowHeadersAsSelectors="false" UseColumnHeadersAsSelectors="false" DayCellToolTipFormat="dddd, dd MMMM, yyyy" NavigationPrevToolTip="เดือนก่อนหน้า" NavigationNextToolTip="เดือนถัดไป" FastNavigationNextToolTip="3 เดือนถัดไป" FastNavigationPrevToolTip="3 เดือนก่อนหน้า">
                                                                <ClientEvents OnDateClick="OnDateClick" OnCalendarViewChanged="OnCalendarViewChanged"></ClientEvents>
                                                                <FastNavigationSettings EnableTodayButtonSelection="true" TodayButtonCaption="ไปที่วันนี้" OkButtonCaption="เปลี่ยน" CancelButtonCaption="ยกเลิก" />
                                                            </telerik:RadCalendar>
                                                        </telerik:RadToolTip>
                                                        &nbsp;<label ID="Label8" runat="server"><font color="red">*</font></label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                    </td>
                                                    <td>
                                                        <asp:RequiredFieldValidator ID="ValReqDate" runat="server" ControlToValidate="txtDate" SetFocusOnError="True" Display="Dynamic" ErrorMessage="* กรุณาระบุวันที่ *"></asp:RequiredFieldValidator>
                                                        <asp:CustomValidator ID="ValDate" runat="server" ErrorMessage="กรุณาระบุวันที่ให้ถูกต้อง" Display="Dynamic" ClientValidationFunction="validateDate" ControlToValidate="txtDate"></asp:CustomValidator>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="20px">
                                    </td>
                                    <td>
                                        <div class="formList-detail">
                                            <table>
                                                <tr>
                                                    <td width="120px" valign="top">
                                                        เรื่อง :
                                                    </td>
                                                    <td>
                                                        <asp:TextBox CssClass="TextBox" ID="txtName" runat="server" Width="450px"></asp:TextBox>
                                                        &nbsp;<label id="Label2" runat="server"><font color="red">*</font></label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                    </td>
                                                    <td>
                                                        <asp:RequiredFieldValidator ID="ValtxtName" runat="server" ControlToValidate="txtName" SetFocusOnError="True" Display="Dynamic" ErrorMessage="* กรุณาระบุเรื่อง *"></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="20px">
                                    </td>
                                    <td>
                                        <div class="formList-detail">
                                            <table>
                                                <tr>
                                                    <td width="120px" valign="top">
                                                        เหตุผลในการจัดหา :
                                                    </td>
                                                    <td>
                                                        <asp:TextBox CssClass="TextBox" ID="txtReason" runat="server" Width="450px" TextMode="MultiLine" Height="55px"></asp:TextBox>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="20px">
                                    </td>
                                    <td>
                                        <table>
                                            <tr>
                                                <td width="120px">
                                                    ต้องการใช้งาน/เสร็จสิ้น :
                                                </td>
                                                <td>
                                                    <asp:RadioButton ID="rdbDuration" runat="server" Text="ภายใน" GroupName="During" Checked="true" />
                                                </td>
                                                <td>
                                                    <asp:Panel ID="panelDuration" runat="server">
                                                        <telerik:RadNumericTextBox ID="txtDurationReq" runat="server" Width="50px" Skin="Outlook" NumberFormat-DecimalDigits="0"></telerik:RadNumericTextBox> 
                                                        <telerik:RadComboBox CssClass="RadComboBox" runat="server" ID="cbDurationType" 
                                                            AllowCustomText="false" ShowDropDownOnTextboxClick="true" Width="80px"
                                                            Filter="Contains" DataTextField="Name" DataValueField="Seq"  MarkFirstMatch="false" OnClientTextChange="onTextChangeGeneral">
                                                        </telerik:RadComboBox>
                                                        &nbsp;นับจาก
                                                        <telerik:RadComboBox CssClass="RadComboBox" runat="server" ID="cbDurationCount" 
                                                            AllowCustomText="false" ShowDropDownOnTextboxClick="true" Width="150px"
                                                            Filter="Contains" DataTextField="Name" DataValueField="Seq" MarkFirstMatch="false" OnClientTextChange="onTextChangeGeneral">
                                                        </telerik:RadComboBox>
                                                    </asp:Panel>  
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="20px">
                                    </td>
                                    <td>
                                        <div class="formList-detail">
                                            <table>
                                                <tr>
                                                    <td width="120px">
                                                        <asp:LinkButton ID="Show_DurationRequired" runat="server" CssClass="LinkButton"  visible="true" CausesValidation="false">
                                                            <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Tree/tree-search.gif" />
                                                        </asp:LinkButton>
                                                        <telerik:RadToolTipManager ID="TipDuration" runat="server" Animation="Fade" 
                                                            HideEvent="Default" OnAjaxUpdate="OnAjaxUpdate_History"  Height="100px" 
                                                            Position="MiddleRight" ShowEvent="OnClick" Skin="Telerik" Width="310px">
                                                        </telerik:RadToolTipManager>
                                                    </td>
                                                    <td>
                                                        <asp:RadioButton ID="rdbDate" runat="server" Text="ภายในวันที่" GroupName="During" />
                                                    </td>
                                                    <td>
                                                        <asp:Panel ID="panelDateReq" runat="server">
                                                            <telerik:RadMaskedTextBox ID="txtDateReq" runat="server" Mask=" ##/##/####" Width="75px" TextWithLiterals=" //" SelectionOnFocus="SelectAll"></telerik:RadMaskedTextBox>
                                                        </asp:Panel>
                                                    </td>
                                                    <td>
                                                        <asp:Panel ID="panelDateReqPick" runat="server">
                                                            <asp:LinkButton ID="LinkButton2" runat="server" CssClass="LinkButton">
                                                                <img alt="" src="../Image/Icon/Calendar.gif" style="border:0px;vertical-align:middle;" />
                                                            </asp:LinkButton>
                                                            <telerik:RadToolTip ID="ToolTipDateReq" runat="server" Animation="None" HideEvent="LeaveToolTip" Position="MiddleRight" ShowEvent="OnClick" Skin="Telerik" 
                                                            TargetControlID="LinkButton2" Modal="true">
                                                                <telerik:RadCalendar id="CalendarDateReq" runat="server" TitleFormat="MMMM yyyy" EnableMultiSelect="false" UseRowHeadersAsSelectors="false" UseColumnHeadersAsSelectors="false" DayCellToolTipFormat="dddd, dd MMMM, yyyy" NavigationPrevToolTip="เดือนก่อนหน้า" NavigationNextToolTip="เดือนถัดไป" FastNavigationNextToolTip="3 เดือนถัดไป" FastNavigationPrevToolTip="3 เดือนก่อนหน้า">
                                                                    <ClientEvents OnDateClick="OnDateReqClick" OnCalendarViewChanged="OnCalendarReqViewChanged"></ClientEvents>
                                                                    <FastNavigationSettings EnableTodayButtonSelection="true" TodayButtonCaption="ไปที่วันนี้" OkButtonCaption="เปลี่ยน" CancelButtonCaption="ยกเลิก" />
                                                                </telerik:RadCalendar>
                                                            </telerik:RadToolTip>
                                                        </asp:Panel>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                    </td>
                                                    <td colspan="2">
                                                        <asp:CustomValidator ID="ValDateReq" runat="server" ControlToValidate="txtDateReq" ErrorMessage="กรุณาระบุวันที่ให้ถูกต้อง" Display="Dynamic" ClientValidationFunction="validateDate"></asp:CustomValidator>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="20px">
                                    </td>
                                    <td>
                                        <div class="formList-detail">
                                            <table>
                                                <tr>
                                                    <td width="120px" valign="top">
                                                        ผู้ดำเนินการ :
                                                    </td>
                                                    <td>
                                                        <telerik:RadComboBox runat="server" ID="cbOperationName" Height="230px" Width="440px" AllowCustomText="true" ShowDropDownOnTextboxClick="true"
                                                            EmptyMessage=".. พิมพ์ที่นี่เพื่อช่วยค้นหา .." MarkFirstMatch="false" ShowMoreResultsBox="true" EnableLoadOnDemand="true" 
                                                            EnableVirtualScrolling="true" HighlightTemplatedItems="true" OnItemsRequested="cbOperationName_ItemsRequested"
                                                            OnClientTextChange="onTextChangeGeneral">
                                                            <HeaderTemplate>
                                                                <table class="font-label" cellpadding="0" cellspacing="0">
                                                                    <tr>
                                                                        <td width="100px" align="center"><b>หน่วยงาน</b></td>
                                                                        <td width="100px" align="center"><b>ชื่อ-สกุล</b></td>
                                                                        <td width="100px" align="center"><b>ตำแหน่ง</b></td>
                                                                        <td width="100px" align="center"><b>ระดับ</b></td>
                                                                    </tr>
                                                                </table>
                                                            </HeaderTemplate>
                                                            <ItemTemplate>
                                                                <asp:Table id="tableOperationName" runat="server" CssClass="font-label" CellPadding="0" CellSpacing="0">
                                                                </asp:Table>
                                                            </ItemTemplate>
                                                        </telerik:RadComboBox>
                                                        &nbsp;<label id="Label14" runat="server"><font color="red">*</font></label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                    </td>
                                                    <td>
                                                        <asp:RequiredFieldValidator ID="ValcbOperationName" runat="server" ControlToValidate="cbOperationName" SetFocusOnError="True" Display="Dynamic" ErrorMessage="* กรุณาระบุผู้ดำเนินการ *"></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" align="center">
                                        <br />
                                        <asp:LinkButton ID="btnSendTo" runat="server" Text="ส่งข้อมูล" 
                                            CssClass="form-button" onclick="btnSendTo_Click"></asp:LinkButton>
                                    </td>
                                </tr>
                            </table>  
                        </div>
                    </td>
                </tr>
            </table>
        </asp:Panel>
    </form>
</body>
</html>
